package com.mjl.usertest.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mjl.usertest.mapper.UserMapper;
import com.mjl.usertest.pojo.User;
import com.mjl.usertest.pojo.UserQuery;
import com.mjl.usertest.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getUsers(UserQuery userQuery) {
        PageHelper.startPage(userQuery.getPageNum(), userQuery.getPageSize());
        return userMapper.getUsers();
    }

    @Override
    public boolean getUser(String name) {
        return userMapper.getUser(name).equals("");
    }

    @Override
    public String login(String name) {
        return userMapper.login(name);
    }
}
